import { Application } from "egg";
import { model } from "../../db";

export default function (app: Application) {
  const App = app.model.define(model.application.table.toUpperCase(), {
    ...model.application.columns,
    ...model.application.virtuals
  });

  // @ts-ignore
  App.associate = function () {
    app.model.Application.belongsTo(app.model.Platform, { foreignKey: "pltId", targetKey: "pltId", as: "platform" });
  };

  return App;
}
